<template>
	<view>
		<view class="new_box">
			<view class="margin-bottom-xs">
				<uni-notice-bar showIcon="true" scrollable="true" single="true" speed="30" background-color="#212327"
					text="欢迎访问嘉天国际物业" color="white">
				</uni-notice-bar>
			</view>
		</view>
		<view class="home_list">
			<view class="home_item" v-for="(item,index) in home_list" :key="index" @click="livelihood(index)">
				<!-- <image :src="item.src"></image> -->
				<view class="iconfont iconColor">{{item.iconfontImg}}</view>
				<view class="text" style="font-size: 28rpx;">{{item.name}}</view>
			</view>
		</view>

		<view class="serve_box">
			<view class="serve_title">功能服务<text class="more" @click="more()">更多</text></view>
			<view class="serve_list">
				<view class="serve_item" v-for="(item,index) in serve_list" :key="index" :mockData="mockData"
					@click="change({index,title:'你好'})">
					<!-- <image :src="item.src"></image> -->
					<view class="iconfont iconColor iconFontSize">{{item.iconfontImg}}</view>
					<view class="text">{{item.name}}</view>
				</view>
			</view>
		</view>



	</view>
</template>

<script>
	import {
		hasOwner
	} from '../../api/owner/ownerApi.js';
	import {
		hasLogin
	} from '../../lib/java110/page/Page.js';

	import {
		getProperty
	} from '../../api/property/propertyApi.js';

	export default {
		name: "indexMenu",
		data() {
			return {
				mockData: "",
				home_list: [],
				serve_list: [],
				callPropertyModal: false,
				property: {}
			};
		},
		created() {
			this._loadFunc();
		},
		methods: {
			_loadFunc: function() {
				this.home_list = [{
							name: '生活缴费',
							src: this.imgUrl + '/h5/images/serve/1.png',
							href: '/pagesA/oweFee/oweFeeType',
							iconfontImg: '\ufaa9',
						},
						{
							name: '家庭成员',
							src: this.imgUrl + '/h5/images/serve/2.png',
							href: '/pagesA/familyList/familyList',
							iconfontImg: '\ue65e',
						},
						{
							name: '报事维修',
							src: this.imgUrl + '/h5/images/serve/6.png',
							href: '/pagesA/repair/repair',
							iconfontImg: '\ue61e',
						},
					],
					this.serve_list = [{
							name: '访客登记',
							src: "../../static/index/index3.png",
							href: '/pagesB/visit/visitList',
							iconfontImg: '\ue6a6',
						},
						{
							name: '更多公告',
							src: "../../static/index/index4.png",
							href: '/pages/notice/index',
							iconfontImg: '\ue638',
						},
						{
							name: '投诉咨询',
							src: "../../static/index/index2.png",
							href: '/pages/complaint/complaint',
							iconfontImg: '\ue6a6',
						}
					]
			},

			to: function(v) {
				if (v.href == '_callPropertyTel') {
					this.callPropertyTel();
				} else {
					this.vc.navigateTo({
						url: v.href
					});
				}
			},
			callPropertyTel: function() { //拨打电话
				let _that = this;
				if (hasLogin()) {
					this.vc.navigateTo({
						url: '../showlogin/showlogin'
					});
					return;
				}
				hasOwner();
				uni.getStorage({
					key: 'ownerInfo',
					success: function(res) {
						_that.property = res.data;
						_that.callPropertyModal = true;
					}
				});
			},
			_doCall: function() {

				let _that = this;
				uni.makePhoneCall({
					// 手机号
					phoneNumber: _that.property.sCommunityTel,
					// 成功回调
					success: (res) => {
						console.log('调用成功!')
					},
					// 失败回调
					fail: (res) => {
						console.log('调用失败!')
					}
				});
			},
			_cancleCall: function() {
				this.callPropertyModal = false;
			},
			more: function() {
				uni.switchTab({
					url: '/pages/homemaking/homemaking'
				})
			},
			// 生活服务
			livelihood: function(index) {
				if (index == 0) {
					uni.navigateTo({
						url: '/pagesA/oweFee/oweFeeType'
					})
				} else if (index == 1) {
					uni.navigateTo({
						url: '/pagesA/familyList/familyList'
					})
				} else if (index == 2) {
					uni.navigateTo({
						url: '/pagesA/repair/repair'
					})
				}
			},
			// 新手指引
			new_guidelines: function(index) {
				if (index == 0) {
					uni.navigateTo({
						url: '../showlogin/showlogin'
					})
				} else if (index == 1) {
					this.callPropertyTel();
				}
			},
			// 功能服务
			change: function(obj, mockData) {
				if (obj.index == 0) {
					uni.navigateTo({
						url: '/pagesB/visit/visitList'
					})
				} else if (obj.index == 1) {
					uni.navigateTo({
						url: '/pages/notice/index'
					})
				} else if (obj.index == 2) {
					uni.navigateTo({
						url: '/pages/complaint/complaint'
					})
				}
			}
		}
	}
</script>

<style lang="less">
	.home_list {
		display: flex;
		margin-bottom: 20rpx;

		.home_item {
			padding: 20upx;
			width: calc((100% - 40rpx) / 3);
			margin-right: 20upx;
			// background: #161616;
			background-color: #212327;
			text-align: center;
			display: flex;
			align-items: center;
			border-radius: 20rpx;
			font-size: 28rpx;
			color: white;

			image {
				height: 40rpx;
				width: 40rpx;
				margin-right: 5rpx;
			}
		}

		.home_item:last-child {
			margin-right: 0;
		}
	}

	.serve_box {
		padding: 0 20rpx;
		background: #292c35;
		// border-radius: 20rpx;
		margin-bottom: 20rpx;

		.serve_title {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx 0rpx 0rpx 0rpx;
			font-size: 30rpx;
			font-weight: 600;
			color: white;

			.more {
				font-size: 24rpx;
				font-weight: 400;
				color: #999;
			}
		}

		.serve_list {
			border-radius: 10rpx;
			display: flex;
			justify-content: space-around;
		}

		.serve_item {
			display: inline-block;
			padding: 20rpx;
			width: 25%;
			// background-color: #292c35;
			text-align: center;
			font-size: 28rpx;

			image {
				height: 64rpx;
				width: 64rpx;
			}

			.text {
				white-space: nowrap;
				font-size: 28rpx;
				font-weight: 400;
				color: white;
			}
		}

		.home_item:last-child {
			margin-right: 0;
		}

	}

	.new_box {
		background: #191b1f;
		padding: 10rpx;

		// .new_wrap {
		// 	display: flex;
		// 	align-items: center;
		// 	justify-content: center;
		// }

		.new_item {
			position: relative;
			display: inline-block;
			padding: 20rpx;
			margin-right: 20rpx;
			width: calc((100% - 40rpx) / 2);
			background: #161616;
			border-radius: 5upx;

			.new_font {
				z-index: 2;
			}

			.name {
				font-size: 28rpx;
				font-weight: 600;
				color: #333;
				text-align: left;
			}

			.text {
				font-size: 24rpx;
				font-weight: 400;
				color: #999;
			}

			image {
				width: 160rpx;
				height: 120rpx;
			}
		}

		.new_item:last-child {
			margin-right: 0;
		}
	}

	/deep/ .uni-noticebar {
		display: flex;
		width: 100%;
		box-sizing: border-box;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		flex-direction: row;
		align-items: center;
		padding: 12rpx 24rpx;
		margin-bottom: 0rpx;
	}

	.iconFontSize {
		width: 130rpx;
		font-size: 70rpx;
		height: 130rpx;
		background: #32323b;
		border-radius: 50%;
		margin: auto;
		text-align: center;
		line-height: 130rpx;
		margin-bottom: 20rpx;
	}
</style>
